<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
	
	<script src="https://d3js.org/d3.v4.min.js" charset="utf-8"></script>
	<script src="./dist_dagre-d3.min.js"></script>
	
	
<style id="css">
body {
  font: 300 14px 'Helvetica Neue', Helvetica;
}

.node rect,
.node circle,
.node ellipse {
  stroke: #333;
  fill: #fff;
  stroke-width: 1px;
}

.edgePath path {
  stroke: #333;
  fill: #333;
  stroke-width: 1.5px;
}

.node rect {
  background: lightblue;
  font-size: 16px;
  color: white;
  width: 50px;
  height: 50px;
}


.screenfull-svg {
    cursor: pointer;
    /*fill: red; */    
   }

</style>
</head>
<body>
	 

<!-- <h1>Dagre D3 Demo: Arrows</h1>  -->

<svg width="1160" height="800" class="screenfull-svg"><g/></svg>

<!-- 
<section>
<p>A sample that shows the different arrows available in dagre-d3.
</section>
 -->
<script id="js">
// Create a new directed graph
var g = new dagreD3.graphlib.Graph().setGraph({});

g.setGraph({
    nodesep: 70,
    ranksep: 50,
    rankdir: "LR", // 流程方向
    marginx: 20,
    marginy: 20
  });

  
// 设置节点
g.setNode('p2', { label: 'p2'});
g.setNode('p', { label: 'p'});
g.setNode('c', { label: 'c'});

var html = `<div style="color: white;background-color: red;">html</div>`
g.setNode('p1', { 
  labelType: 'html',
  label: html,
  rx: 0, // 圆角
  ry: 0,
  // padding: 0,
});
g.setNode('c1', { label: 'c'});
debugger
// 连接线 （start, end, lineStyle）
g.setEdge('c', 'p', {
  arrowhead: 'normal',
  label: 'zzz'
});
g.setEdge('c', 'p2', {
  arrowhead: 'normal',
  label: ''
});

var svg = d3.select('svg');
var inner = svg.select('g');

// 可以收缩放大
var zoom = d3.zoom().on("zoom", function() {
      inner.attr("transform", d3.event.transform);
    });
svg.call(zoom);

// 渲染到页面
var render = new dagreD3.render();
render(inner, g);

var initialScale = 0.75;
svg.call(zoom.transform, d3.zoomIdentity.translate((svg.attr("width") - g.graph().width * initialScale) / 2, 20).scale(initialScale));
svg.attr('height', g.graph().height * initialScale + 40);

</script>
</body>
</html>
